#define _CRT_SECURE_NO_WARNINGS 1

#include <stdio.h>
#include <stdbool.h>
#include <math.h>


bool isHappy(int n) {
    int i = 0;
    int orgin = n;
    int total = 0;
    int count = 0;
    while (total != 1)
    {
        total = 0;
        while (n)
        {
            i = n % 10;
            n /= 10;
            total += pow(i, 2);
        }
        n = total;
        count++;
        if (total == 1)
        {
            return true;
        }
        if (count == 100)
        {
            return false;
        }
    }
    return false;
}

int main()
{
    printf("%d ",isHappy(19));
    return 0;
}